"""
异步IO-asyncio模块

Version: 0.1
Author: yuwl
Date：2024-4-9
"""

import asyncio
import threading
import time

async def hello():
    print(f'{threading.current_thread().name}: hello, world!')
    await asyncio.sleep(2)
    # time.sleep(3)
    print(f'{threading.current_thread().name}: goodbye, world!')

async def main():
    # 创建任务
    tasks = [asyncio.create_task(hello()), asyncio.create_task(hello())]

    # 等待任务完成
    await asyncio.wait(tasks)

# 运行主函数
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
print('game over')
loop.close()



